# 10.3
from pathlib import Path

path = Path('day14/pi_digits.txt')
contents = path.read_text()
for line in contents.splitlines():
    print(line)


# learning_c.py
path = Path('day14/learning_python.txt')
contents = path.read_text()

# print(contents)

for line in contents.splitlines():
    line = line.replace('Python','c')
    print(line)


# file_reader.py
# 相对路径
path = Path('day14/pi_digits.txt')  # 程序文件存储在ptthon_work中,
                                    # Python只会在python_work中查找
contents = path.read_text()
contents = contents.rstrip()        # 删除多出来的空格,
                                    # 也可这样写：contents = path.read_text().restrip()
print(contents)
for line in contents.splitlines():
    print(line)


# pi_string_2.py
path = Path('day14/pi_million_digits.txt')
contents = path.read_text()

pi_srting =""                       # splitlines() 将字符串转换为一系列行
for line in contents.splitlines():
    pi_srting +=line.lstrip()       # lstrip() 删除每行左端空格

print(f"{pi_srting[:52]}...")
print(len(pi_srting))

birthday = input("Enter your biryhday, in the form mmddyy: ")
if birthday in pi_srting:
    print("Your birthdy appears in the first million digits of pi!")

else:
    print("Your birthdy does not appears in the first million digits of pi!")